package server.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import server.business.pojo.Businessmsg;
import server.business.pojo.Front;

import java.util.List;

@Mapper
public interface BusinessmsgMapper extends BaseMapper<Businessmsg> {

    /**
     * 根据医生查询业务
     * @param currentposition 医生
     * @return
     */
    @Select("select * from t_bussinessmsg where currentposition = #{currentposition}")
    public List<Businessmsg> getBusinessMsg(String currentposition);


    /**
     * 更新信息
     * @param id 当前执行的id
     * @param currentprocess 下一个流程名称
     * @param currentposition 下一个医生姓名
     */
    @Select("update t_bussinessmsg set currentprocess = #{currentprocess},currentprocess1 = #{currentprocess1},currentposition = #{currentposition},msg = #{msg},operationhistory = #{operatehistory} where id = #{id}")
    public void updateProcess(Integer id,String currentprocess,
                              String currentprocess1,
                              String currentposition,
                              String msg,
                              String operatehistory);

    /**
     * 多表查询获取数据
     * @param page page
     * @param doctorid doctor id
     * @return
     */
    @Select("select b.id,a.bussnessname,c.frontpath from t_allbusiness as a left join t_bussinessmsg as b on a.id = b.bussinessid left join t_process as c on b.currentprocess1 = c.id where b.currentposition = #{doctorid}")
    public IPage<Front> selectListInfoByPage(Page<Front> page, String doctorid);


    @Select("select * from t_bussinessmsg")
    public IPage<Businessmsg> selectList(Page<Businessmsg> page);
}
